﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Inspired.Euler
{
    /// <summary>
    /// 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
    /// 
    /// What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?
    /// </summary>
    public static class Problem005
    {
        /// <summary>
        /// What is the smallest number divisible by each of the numbers 1 to 20?
        /// </summary>
        [EulerProblem(5, Title = "What is the smallest number divisible by each of the numbers 1 to 20?")]
        public static long Solve()
        {
            IEnumerable<int> divisors = Enumerable.Range(2, 18);
            for (long i = 22; i < Int64.MaxValue; i += 2)
            {
                if (divisors.Any(d => i % d != 0))
                    continue;

                return i;
            }
            return -1;
        }
    }
}
